<template>
  <div class="myLogin">
    <div class="rollback" @click="jumpFn">
      <span class="iconfont icon-arrowLeft-fill"></span>
    </div>
    <div class="rolltitle">
      <span>注册孤岛</span>
    </div>
    <!-- 登录 -->
    <div class="loginout">
      <div class="telephone">
        <span>+86</span>
        <input type="text" v-model="userphone" placeholder="手机号" />
      </div>
      <div class="password">
        <input type="password" v-model="userpassword" placeholder="密码" />
      </div>
    </div>
    <!-- 点击 -->
    <div class="user_hits">
      <button @click="loginIn">下一步</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userphone: "",
      userpassword: "",
    };
  },
  methods: {
    //路由返回
    jumpFn() {
      this.$router.go(-1);
    },
    loginIn() {
      if (this.userphone.length == 0 || this.userpassword.length == 0) {
        return;
      }
      let phone = this.userphone;
      let password = this.userpassword;
    //   console.log(phone, password);

      //判断是否为手机号码
      if (!/^1[3-9]\d{9}$/.test(phone)) {
        alert("手机号码格式错误!请重新填写");
        this.userphone = "";
        this.userpassword = "";
      }
      //注册成功则跳转
      else if(/^1[3-9]\d{9}$/.test(phone)) {
        let userobj = {};
        userobj.phone = phone;
        userobj.password = password;
        sessionStorage.setItem("userobj", JSON.stringify(userobj));
        this.$router.push("/mylogin");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.myLogin {
  width: 100%;
  height: 100%;
  background: #fff;
}
.rollback {
  height: 50px;
  padding-top: 15px;
  padding-left: 15px;
  span {
    font-size: 30px;
  }
}
.rolltitle {
  height: 100px;
  font-size: 30px;
  padding-left: 15px;
  padding-top: 20px;
}
.loginout {
  padding-left: 15px;
  .telephone {
    height: 60px;
    span {
      font-size: 18px;
      padding-bottom: 12px;
      border-bottom: 1px solid #a1a1a1;
    }
    input {
      width: 280px;
      height: 40px;
      border: transparent;
      outline: none;
      font-size: 18px;
      border-bottom: 1px solid #a1a1a1;
      margin-left: 15px;
    }
  }
  .password {
    height: 60px;
    input {
      width: 320px;
      height: 40px;
      border: transparent;
      outline: none;
      font-size: 20px;
      border-bottom: 1px solid #a1a1a1;
    }
  }
}

.user_hits {
  height: 361px;
  button {
    width: 300px;
    height: 50px;
    border-radius: 20px;
    text-align: center;
    margin-left: 30px;
    margin-top: 30px;
    border: none;
    color: #fff;
    background: #ff672c;
  }
  .user_sign {
    height: 50px;
    padding-top: 20px;
    text-align: center;
    color: #ff672c;
    font-size: 18px;
  }
}
</style>